package com.business.yang.mvp.view.find.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.business.yang.R;
import com.business.yang.core.BaseMainActivity;
import com.business.yang.mvp.presenter.find.FindPresenter;
import com.business.yang.mvp.view.find.view.IFindParentView;
import com.lyxs916.utilslibrary.view.SupperToolBar;

import butterknife.BindView;
import butterknife.OnClick;

public class FindActivity extends BaseMainActivity<IFindParentView.IFindView, FindPresenter>
        implements IFindParentView.IFindView {
    @BindView(R.id.toolbar)
    SupperToolBar toolbar;
    @BindView(R.id.text)
    TextView text;
    @BindView(R.id.text2)
    TextView text2;
    @BindView(R.id.parentText)
    RelativeLayout parentText;

    @BindView(R.id.parentText2)
    RelativeLayout parentText2;

    public static void startUi(Context context) {
        Intent intent = new Intent(context, FindActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    @Override
    public int setContentView() {
        return R.layout.activity_find;
    }

    @Override
    public void parseIntent(Intent intent) {
    }

    @Override
    public int currentItem() {
        return 1;
    }

    @Override
    public void initView() {
        super.initView();
        toolbar.setTitle("发现");
        presenter.requestHttpData(true, parentText);
        presenter.defeat(true, parentText2);

    }

    @Override
    public FindPresenter initPresenter() {
        return new FindPresenter();
    }


    @OnClick(R.id.refresh)
    public void onViewClicked() {
        text.setText("正在请求...");
        text2.setText("正在请求...");
        presenter.requestHttpData(false, parentText);
        presenter.requestHttpData2(true, parentText2);
    }

    @Override
    public void resultData(final String data) {
        text.setText(data);
        text2.setText(data);


    }

    @Override
    public void coreOnLoadingBarListener(View parent) {
        if (parent != null) {
            Toast.makeText(mActivity, "点击了***" + parent.getId(), Toast.LENGTH_SHORT).show();
        }
    }

}
